﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GrewalCRM.BLL;
using GrewalCRM.Entities;
using GrewalCRM.Entities.Common;

public partial class MonthlyReportPrint : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
      gvDlrCallCallSummary.DataSource = DLRInstallationSummary;
      gvDlrCallCallSummary.DataBind();
      DLRInstallationSummary = null;

      if (DLRInstallationDetails != null && DLRInstallationDetails.Count > 0)
      {
        gvDlrCallDetails.DataSource = DLRInstallationDetails;
        gvDlrCallDetails.DataBind();
        lblDealerValue.Text = DLRInstallationDetails[0].Dealer.DealerCounterName;
        lblMonthValue.Text = ((Month)DLRInstallationDetails[0].CallReceiveDate.Value.Month).ToString();
        lblDatedValue.Text = DateTime.Now.ToShortDateString();
      }
      DLRInstallationDetails = null;
    }

    private List<ReportInstallationSummary> DLRInstallationSummary
    {
      set
      {
        if (value != null)
          Cache["DLR_INSTL_SMRY"] = value;
        else
          Cache.Remove("DLR_INSTL_SMRY");
      }
      get
      {
        if (Cache["DLR_INSTL_SMRY"] != null && Cache["DLR_INSTL_SMRY"] is List<ReportInstallationSummary>)
          return Cache["DLR_INSTL_SMRY"] as List<ReportInstallationSummary>;
        else
        {
          return new List<ReportInstallationSummary>();
        }
      }
    }
    private List<CallLog> DLRInstallationDetails
    {
      set
      {
        if (value != null)
          Cache["DLR_INSTL_DTLS"] = value;
        else
          Cache.Remove("DLR_INSTL_DTLS");
      }
      get
      {
        if (Cache["DLR_INSTL_DTLS"] != null && Cache["DLR_INSTL_DTLS"] is List<CallLog>)
          return Cache["DLR_INSTL_DTLS"] as List<CallLog>;
        else
        {
          return new List<CallLog>();
        }
      }
    }
    protected void gvDlrCallCallSummary_RowDataBound(object sender, GridViewRowEventArgs e)
    {
      if (e.Row.RowType == DataControlRowType.DataRow)
      {
        Label lblStatusName = e.Row.FindControl("lblStatusName") as Label;

        if (lblStatusName != null && lblStatusName.Text.ToUpper().Trim() == "TOTAL")
        {
          lblStatusName.Font.Bold = e.Row.Font.Bold = true;
        }
      }
    }
}